package com.car.ljc.entity;

/**
 * 车子信息
 * @Author ljc
 * @Date 2018/9/20 14:44
 */
public class Car {
    private int level;//车子等级
    private int state;//车子状态 0-未开箱 1-未在跑道 2-已在跑道
    private int pos;//车子的位置（从0开始）

    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    public int getPos() {
        return pos;
    }

    public void setPos(int pos) {
        this.pos = pos;
    }

    /**
     * 位置相同的车子代表为同一个车
     * @return
     */
    @Override
    public int hashCode() {
        return this.pos;
    }

    @Override
    public boolean equals(Object obj) {
        if(obj instanceof Car){
            Car car = (Car)obj;
            return car.getPos() == this.pos;
        }
        return false;
    }
}
